<!--
 * @Author: MrLee
 * @Date: 2024-08-24 08:55:14
 * @LastEditors: MrLee
 * @LastEditTime: 2024-08-24 11:40:26
 * @Description: 请填写简介
-->
<template>
    <custom-navbar title="求内推" :autoBack="true" leftIconColor="#303133" />
    <up-gap height="30rpx" />
    <view class="px-24rpx">
    <view class="text-[#1d2129] text-[30rpx] py-24rpx">内推岗位</view>
    <view class="bg-#f6f7f8">
        <view
          v-for="(item, index) in jobList"
          :key="index"
          class="job-item  bg-#fff px-40rpx py-24rpx rounded-[20rpx]"
        >
          <view class="mb-14rpx flex items-center justify-between">
            <view class="text-left text-[32rpx] text-[#1d2129]">
              {{ item.job_name }}
            </view>
            <view
              class="text-[30rpx] text-[#1f50f2] font-semibold tracking-[-0.3rpx]"
            >
              {{item.salary_min}}k-{{item.salary_max}}k·{{item.salary_count}}薪
            </view>
          </view>
          <view
            class="mb-24rpx flex items-center text-left text-[26rpx] text-[#6e6d72]"
          >
            <view>{{item.province}}·{{item.city}}</view>
            <view class="mx-10rpx h-28rpx w-2rpx bg-#6e6d72" />
            <view>{{item.job_nature}}</view>
            <view class="mx-10rpx h-28rpx w-2rpx bg-#6e6d72" />
            <view>{{item.qualifications}}</view>
          </view>
          <view
            class="mb-20rpx flex items-center justify-between b-b b-b-#f6f7f8 b-b-solid pb-18rpx"
          >
            <view class="flex items-center">
              <view
                class="mr-10rpx bg-#fcf8e9 px-8rpx color-#f57100 leading-42rpx"
                v-for="ite in item.highlights"
              >
                {{ite}}
              </view>
            </view>
          </view>
          <navigator class="flex items-center text-[26rpx] text-[#4e5968]" url="/pages/common/company/index" hover-class="none">
            <image
              class="mr-12rpx h-36rpx w-36rpx rounded-full"
              :src="item.hr_avatar"
            />
            <view>{{item.company_name}}</view>
            <view class="mx-10rpx h-28rpx w-2rpx bg-#6e6d72" />
            <view>{{item.company_type}}</view>
            <view class="mx-10rpx h-28rpx w-2rpx bg-#6e6d72" />
            <view>{{item.company_listed}}</view>
          </navigator>
          <view
            class="flex items-center justify-between text-[26rpx] text-[#4e5968]"
          >

          </view>
        </view>
      </view>
      <view class="text-[#1d2129] text-[30rpx] py-24rpx">请选择内推老师</view>
      <view class=" bg-#fff px-40rpx py-24rpx rounded-[20rpx]">
        <search-bar />
        <view class="flex items-center justify-between mt-24rpx">
            <view class="bg-#f6f6f6 rounded-[34rpx] py-16rpx px-18rpx flex items-center justify-between w-43%">
                <view class="text-[#bebebe]">请选择院系</view>
                <view class="iconfont icon-xiajiantou"></view>
            </view>
            <view class="bg-#f6f6f6 rounded-[34rpx] py-16rpx px-18rpx flex items-center justify-between w-43%">
                <view class="text-[#bebebe]">老师职务</view>
                <view class="iconfont icon-xiajiantou"></view>
            </view>
        </view>
        <view class="w-100% h-2rpx bg-#ebebeb mt-28rpx"></view>

        <view
        v-for="(item, index) in list"
        :key="index"
        class="job-item mb-32rpx py-24rpx "
        style="border-bottom: 1px dashed #ededed;"
      >
        <view
          class="flex items-start py-24rpx justify-between"
        >
          <view class="relative mr-[20rpx]">
            <image
              src="https://yiliao.test03.qcw800.com/static/images/tab/user-01.png"
              class="block h-[20rpx] w-[20rpx] absolute rigth-0 bottom-[5rpx]"
              style="right: 0"
            />
            <image class="w-72rpx h-72rpx rounded-[50%]" :src="item.headerUrl" />
          </view>
          <view class="flex flex-col justify-center">
            <view class="mb-4rpx flex items-center justify-between">
              <view class="text-left text-[32rpx] text-[#1d2129]">
                {{ item.name }}
              </view>
            </view>
            <view
              class="flex flex-col items-start text-left text-[26rpx] text-[#6e6d72]"
            >
              <view
                v-for="(itemTab, indexTab) in item.tabs"
                :key="indexTab"
                class="flex flex-col items-center justify-center"
              >
                <view
                  :class="itemTab.className"
                  class="text-[24rpx] font-medium"
                  >{{ itemTab.label }}</view
                >
              </view>
            </view>
          </view>
          <view class=" text-[#7b7b7b] bg-#f7f7f8 w-112rpx h-44rpx flex items-center justify-center rounded-[22rpx]">选择</view>
        </view>
      </view>
      </view>
    </view>
    <view class="fixed bottom-0 h-178rpx w-[100%] bg-#fff shadow-[0px_0px_12px_0px_rgba(238,239,241,0.50)]">
        <view
            class="mx-auto my-0 mt-[24rpx] h-82rpx w-[90%] rounded-[42rpx] bg-#1f50f2 text-center text-[30rpx] text-white font-medium leading-[82rpx]">
            确定
        </view>
    </view>
  </template>
 <script setup lang="ts">
   import { userJobDetail, teacherList } from '@/api/user';
 // import home01 from '@/static/images/tab/home-01.png';
 // import userCatch01 from "@/static/images/tab/user-header.png";
 const home01 = 'https://yiliao.test03.qcw800.com/static/images/tab/home-01.png'
 const userCatch01 = 'https://yiliao.test03.qcw800.com/static/images/tab/user-header.png'

 const jumpDetail = (job_id:number) => {
   uni.navigateTo({
       url: '/pages/common/position-detail/index?job_id='+job_id
     });

 }

 const jobList:any = reactive({});

 async function getJobDetail(job_id: number = 0) {
   let params:any = {
     job_id: job_id
   }
   let r = await userJobDetail(params);
   console.log('职位详情 res:::', r);
   let rr:any = {
     job_name: r.name,
     job_id: r.id,
     salary_min: r.salary_min,
     salary_max: r.salary_max,
     salary_count: r.salary_count,
     province: r.province.name,
     city: r.city.name,
     job_nature: r.nature,
     job_content: r.job_content,
     job_requirements: r.job_requirements,
     qualifications: '',
     highlights: r.highlights,
     company_id: r.company.id,
     company_logo: r.company.url_logo,
     company_name: r.company.name,
     company_type: r.company.type == 1 ? '民营': r.company.type == 2 ? '国企' : '合资',
     company_listed: r.company.listed == 1 ? '未上市': '上市',
     address: r.address_detail,
     like: r.like,
     hr_avatar: r.user.avatar,
     hr_name: r.user.name,
     hr_duty: r.user.hr.duty.name,
     hr_id: r.user.id,
     email: r.adress_email,
     tabs: []
   }
   let qualifications = ''
   for (let j = 0; j < r.qualifications.length; j++) {
     qualifications += r.qualifications[j] + ' '
   }
   rr.qualifications = qualifications
   rr.tabs = [
       {
         label: rr.province+"·"+rr.city,
         ico: "icon-a-zu121328_1",
       },
       {
         label: rr.job_nature,
         ico: "icon-a-zu121326_1",
       },
       {
         label: rr.qualifications,
         ico: "icon-a-zu121327_1",
       },
     ],
   jobList.value = rr;
 }

 const list: any = reactive([]);
 async function getTeacherRecommendList(params:any) {
   let result = await teacherList(params);
   console.log('老师列表 res list:::', result);
   for (let i = 0; i < result.list.length; i++) {
     const r = result.list[i]
     let rr: any = {
       name: r.user.name,
       headerUrl: r.user.avatar,
       tabs: [
         {
           label: r.school.name,
           ico: "icon-a-zu121328_1",
           className: "text-[#4e5969]",
         },
         {
           label: r.college.name+" | "+r.duty.name,
           ico: "icon-a-zu121326_1",
           className: "text-[#1d2129]",
         },
       ],
       date: "09-04",
     }
     list.push(rr)
   }
 }

 onLoad((query:any)=>{
   console.log('内推页面 职位ID:::', query.job_id)
   getJobDetail(query.job_id);
   getTeacherRecommendList({
      name: "大"
   });
 })
 </script>
